package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    @Select("select count(*) from sky_take_out.dish where category_id =#{category_id}")
    Long selectca(Integer category_id);


    @AutoFill(value = OperationType.INSERT)
    void InsertDish(Dish dish);


    Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);

    @Select("select d.*,c.name as categoryName from sky_take_out.dish d left join sky_take_out.category c on d.category_id = c.id where d.id=#{id} ;")
    DishVO getbyid(Long id);


    void deletebyids(List <Long> ids);
    @Select("select d.*,c.name as categoryName from sky_take_out.dish d left join sky_take_out.category c on d.category_id = c.id where d.category_id=#{categoryId} ;")
    List <DishVO> getbycategoryId(Long categoryId);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

   @AutoFill(OperationType.UPDATE)
    void updatestatus(Dish dish);

   @Select("SELECT sd.copies as copies,d.description as description , d.image as image , d.name as name FROM sky_take_out.dish d,sky_take_out.setmeal_dish sd where sd.dish_id=d.id and sd.setmeal_id =#{setmealId}")
   List <DishItemVO> getbysetmealid(Long setmealId);

    List<Dish> list(Dish dish);

    Integer countByMap(Map map);
}
